package com.forenow.demo4;

public class Master {
    public void cure(Pet pet){
        if (pet.getHealth()<50){
            pet.toHosipital();
            System.out.println(pet.getName()+"吃药...");
        }else{
            System.out.println(pet.getName()+"身体杠杠的");
        }
    }

    public static void main(String[] args) {
        Master master= new Master();
        Pet p = new Dog();
        p.setName("京东");
        p.setHealth(40);
        p.setLove(100);
        master.cure(p);

        p = new Dog();
        p.setName("QQ");
        p.setHealth(20);
        p.setLove(99);
        master.cure(p);
    }
}
